#include <vector>

#include "GlGameListener.h"
#include "GlSize.h"
#include "GlPosition.h"
#include "GlSprite.h"
#include "GlSection.h"

namespace SneakingMission
{
// 	class Point
// 	{
// 	public:
// 		Point();
// 		Point(float x_, float y_);
// 		float getX();
// 		float getY();
// 		void setX(float x);
// 		void setY(float y);
// 		Point operator=(Point p);
// 		bool operator==(Point p);
// 	private:
// 		float x;
// 		float y;
// 	};

	//void move(Point from, Point to, float speed);

	class Enemy
	{
	public:
		Enemy();
		GraphicLibrary::Position getPosition();
		void addPointToRoute(GraphicLibrary::Position p);
		void step(const float deltaTime);
		void setSprite(const char *s);
		inline void setSpeed(float s)
		{
			if(s<1)
			{
				speed = 1;
			}
			else if(s>10)
			{
				speed = 10;
			}
			else
			{
				speed = s;
			}			
		}
		inline float getSpeed()
		{
			return speed;
		}
		inline GraphicLibrary::Sprite *getSprite()
		{
			return sprite;
		}
	private:
		std::vector<GraphicLibrary::Position> route;
		int nextPoint;
		float speed;
		GraphicLibrary::Position position;
		GraphicLibrary::Sprite *sprite;
	};

	class Player
	{
	public:
		Player();
		//Player(GraphicLibrary::Position pos);
		void setTarget(GraphicLibrary::Position targ, float withMinusStep = 0.0f);
		void setPosition(GraphicLibrary::Position pos);
		inline void setSpeed(float newSpeed) { speed = newSpeed; }
		inline float getSpeed() { return speed; }
		inline void slowSpeed() { speed = SLOW_SPEED; }
		inline void normalSpeed() {speed = NORMAL_SPEED; }
		float getTargetX();
		float getTargetY();
		GraphicLibrary::Position getPosition();
		inline GraphicLibrary::Position getTarget()
		{
			return target;
		}
		void step(GraphicLibrary::Sprite *s, const float deltaTime);
		void initLife(int lifeNum);
		bool death();
		inline int getLife()
		{
			return life;
		}
	private:
		GraphicLibrary::Position position;
		GraphicLibrary::Position target;
		GraphicLibrary::Section* section;
		int life;
		float speed;
		const float SLOW_SPEED;
		const float NORMAL_SPEED;
	};	

	

	class Wall
	{
	public:
		Wall(GraphicLibrary::Position pos1, GraphicLibrary::Position pos2, std::string newColor);
		GraphicLibrary::Position getPosition1();
		GraphicLibrary::Position getPosition2();
		GraphicLibrary::Position getCollisionPosition1(float collisionWidth);
		GraphicLibrary::Position getCollisionPosition2(float collisionWidth);
		inline std::string getColor() { return color; }
		void setSprite(const char *s);
		inline void setWeight(const float w)
		{
			weight = w;
		}
		inline float getWeight()
		{
			return weight;
		}
		inline GraphicLibrary::Sprite* getSprite()
		{
			return sprite;
		}
		inline bool isHorizontal()
		{
			return position1.mY == position2.mY;
		}
	private:
		GraphicLibrary::Position position1;
		GraphicLibrary::Position position2;
		float weight;
		GraphicLibrary::Sprite* sprite;
		std::string color;
	};

	class SlowField
	{
	public:
		SlowField(GraphicLibrary::Position pos1, GraphicLibrary::Position pos2);
		GraphicLibrary::Position getPosition1();
		GraphicLibrary::Position getPosition2();
		bool isCollision(GraphicLibrary::Position playerPos);
		void setSprite(const char *s);
		inline GraphicLibrary::Sprite* getSprite()
		{
			return sprite;
		}
	private:
		GraphicLibrary::Position position1;
		GraphicLibrary::Position position2;
		GraphicLibrary::Sprite* sprite;
	};


	class Key
	{
	public:
		Key(GraphicLibrary::Position pos, std::string newColor);
		GraphicLibrary::Position getPosition();
		void setPosition(GraphicLibrary::Position pos); 
		inline bool isAcquired() { return acquired; }
		inline void acquire() { acquired = true; }
		inline std::string getColor() { return color; }
		void setSprite(const char *s);
		inline GraphicLibrary::Sprite* getSprite()
		{
			return sprite;
		}
	private:
		bool acquired;
		std::string color;
		GraphicLibrary::Position position;
		GraphicLibrary::Sprite* sprite;
	};
}